import { useState } from 'react';
const Demo = () => {
  const [count, setCount] = useState(0);
  const changeCount = () => {
    setCount(count + 1);
    setCount(count + 1);
    setCount(count + 1);
    setCount(count + 1);
    setCount(count + 1);
    setCount(count + 1);
    console.log('count', count);
  };
  const changeCountCallback = () => {
    setCount((count) => count + 1);
    setCount((count) => count + 1);
    setCount((count) => count + 1);
    setCount((count) => count + 1);
    setCount((count) => count + 1);
    setCount((count) => count + 1);
    console.log('count', count);
  };
  return (
    <div>
      <h1>State Demo 1</h1>
      <p>count: {count}</p>
      <button onClick={() => changeCount()}>add</button>
      <button onClick={() => changeCountCallback()}>add callback</button>
    </div>
  );
};

export default Demo;
